package capricornus.components.tilelist
{
	import capricornus.components.event.ComponentsEvent;
	
	import flash.display.DisplayObject;
	
	public class ComplexList extends TileList
	{
		public function ComplexList(row:int=0)
		{
			super(row);
		}
		
		override public function addItem(item:DisplayObject):void
		{
			super.addItem( item );
			item.addEventListener( ComponentsEvent.RESIZE, onComponentResize, false, 0, true );
		}
		
		override public function addItemAt(item:DisplayObject, index:int):void
		{
			super.addItemAt( item, index );
			item.addEventListener( ComponentsEvent.RESIZE, onComponentResize, false, 0, true );
		}
		
		private function onComponentResize( e:ComponentsEvent ):void
		{
			refresh();
		}
		
		override protected function destroyItem(item:DisplayObject):void
		{
			item.removeEventListener( ComponentsEvent.RESIZE, onComponentResize );
		}
	}
}